import request from "@/axios/request";
import url from "@/axios/url";
import { technologyDialog } from '@/views/process/mesProcessMaterial/technologyMixin'
const { mesUrl, adminUrl } = url();

// 导出url
export const exportUrl = `${mesUrl}mesProcessMaterial/export`
// 下载模板
export const downloadTemplateUrl = `${mesUrl}mesProcessMaterial/template`

// 分页查询
export function getList (params = {}) {
  return request({
    url: `${mesUrl}mesProcessMaterial`,
    method: "GET",
    params,
  });
}

// 新增
export function rowCreate (data = {}) {
  return request({
    url: `${mesUrl}mesProcessMaterial/addMesProcessMaterial`,
    method: "POST",
    data,
  });
}

// 修改
export function rowUpdate (data = {}) {
  return request({
    url: `${mesUrl}mesProcessMaterial/updateMesProcessMaterial`,
    method: "PUT",
    data,
  });
}

// 删除
export function rowDel (id) {
  return request({
    url: `${mesUrl}mesProcessMaterial/${id}`,
    method: "PUT",
  });
}

// 详情
export function rowDetail (id) {
  return request({
    url: `${mesUrl}mesProcessMaterial/info/${id}`,
    method: "get",
  });
}

// 查询物料编码列表
export function getMaterialCodeList (params) {
  return request({
    url: `${adminUrl}baseGoods`,
    method: "GET",
    params,
  });
}

// 查询工序编码列表
export function getProcessCodeList () {
  return request({
    url: `${mesUrl}mesProcess/list`,
    method: "GET",
  });
}

// 物料列表
export function getMaterialList (params) {
  return request({
    url: `${adminUrl}baseGoods`,
    method: "GET",
    params,
  });
}

// 查询工艺列表
export function getTechnologyList (params) {
  return request({
    url: `${mesUrl}mesTechnology`,
    method: "GET",
    params,
  });
}

// 查询物料编码列表
export function getMaterialCodeListAll (params) {
  return request({
    url: `${adminUrl}baseGoods/list`,
    method: "GET",
    params,
  });
}

// 查询物料编码列表 筛选指定产品
export function pageExclude (params) {
  return request({
    url: `${adminUrl}baseGoods/pageExclude`,
    method: "get",
    params,
  });
}
// 正则表达式列表
export function getRegularList (data = {}) {
  return request({
    url: `${adminUrl}commonRegularConfiguration/page`,
    method: "POST",
    data,
  });
}

// 查询系列列表
export function getSeriesList (params = {}) {
  return request({
    url: `${adminUrl}baseSeries/selectlist`,
    method: "GET",
    params,
  });
}

// 获取工序列表，新增时，类型为工艺，type=0
export function getProcessList (type, id) {
  return type === '0' ? getTechnologyProcessList(id) : getOtherProcessList();
}

// 获取工序列表，新增时，类型为工艺时
export function getTechnologyProcessList (id) {
  return request({
    url: `${mesUrl}mesTechnology/getProcessByTechId/${id}`,
    method: "GET",
  });
}

// 获取工序列表，新增时，类型不是工艺时
export function getOtherProcessList () {
  return request({
    url: `${mesUrl}mesProcess/list`,
    method: "GET",
  });
}


